<!DOCTYPE html>
<html>

<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<meta name="theme-color" content="#33474d">
	<title>zabbix 服务端安装 | 失落的乐章</title>
	<link rel="stylesheet" href="/css/style.css" />
	
      <link rel="alternate" href="/atom.xml" title="失落的乐章" type="application/atom+xml">
    
</head>

<body>

	<header class="header">
		<nav class="header__nav">
			
				<a href="/archives" class="header__link">Archive</a>
			
				<a href="/tags" class="header__link">Tags</a>
			
				<a href="/atom.xml" class="header__link">RSS</a>
			
		</nav>
		<h1 class="header__title"><a href="/">失落的乐章</a></h1>
		<h2 class="header__subtitle">技术面前，永远都是学生。</h2>
	</header>

	<main>
		<article>
	
		<h1>zabbix 服务端安装</h1>
	
	<div class="article__infos">
		<span class="article__date">2017-10-12</span><br />
		
		
			<span class="article__tags">
			  	<a class="article__tag-link" href="/tags/Zabbix/">Zabbix</a>
			</span>
		
	</div>

	

	
		<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;zabbix 是另外一个用得比较多的监控工具，同样也需要 apache+php 的支持，但它比 nagios 要多一个 mysql ，因为它有数据需要储存。所以，安装 zabbix，必须要安装 mysql 。</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;在安装 zabbix 之前，也需要安装 epel 扩展源，因为 centos 自带 yum 源是没有 zabbix 的。</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">[root@zabbix ~]<span class="comment"># yum install -y epel-release</span></div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;安装 rpm 包的 lamp 环境</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">[root@zabbix ~]<span class="comment"># yum install -y httpd mysql mysql-libs php php-mysql mysql-server php-bcmath php-gd php-mbstring</span></div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;安装 zabbix 服务端</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">[root@zabbix ~]<span class="comment"># yum install -y zabbix30 zabbix30-agent zabbix30-server zabbix30-server-mysql zabbix30-web zabbix30-web-mysql net-snmp-devel</span></div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;安装好以后，就可以启动服务了</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">[root@zabbix ~]<span class="comment"># service zabbix-server start</span></div><div class="line">[root@zabbix ~]<span class="comment"># service zabbix-agent start</span></div><div class="line">[root@zabbix ~]<span class="comment"># service httpd start</span></div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;修改一下 mysql 配置</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">[root@zabbix ~]<span class="comment"># vim /etc/my.cnf</span></div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;修改或增加内容</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line">[mysql]</div><div class="line">default-character-set = utf8</div><div class="line">[mysqld]</div><div class="line">character_set_server = utf8</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;然后启动 mysql 服务</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">[root@zabbix ~]<span class="comment"># /etc/init.d/mysqld start</span></div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;然后建库，导入数据</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line">[root@zabbix ~]<span class="comment"># mysql -uroot -e "create database zabbix"</span></div><div class="line">[root@zabbix ~]<span class="comment"># mysql -uroot --default-character-set=utf8 zabbix &lt; /usr/share/zabbix-mysql/schema.sql</span></div><div class="line">[root@zabbix ~]<span class="comment"># mysql -uroot --default-character-set=utf8 zabbix &lt; /usr/share/zabbix-mysql/images.sql </span></div><div class="line">[root@zabbix ~]<span class="comment"># mysql -uroot --default-character-set=utf8 zabbix &lt; /usr/share/zabbix-mysql/data.sql</span></div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;这时发现 zabbix_server 并没有启动起来</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">[root@zabbix ~]<span class="comment"># mysql -uroot -e "grant all on *.* to 'zabbix'@'localhost' identified by 'zabbix';"</span></div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;编辑 /etc/zabbix/zabbix_server.conf </p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">[root@zabbix ~]<span class="comment"># vim /etc/zabbix/zabbix_server.conf</span></div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;配置 DBUser，DBPasseord </p>
<p><figure class="figure"><img src="https://github.com/hcldirgit/image/blob/master/zabbix%20%E6%9C%8D%E5%8A%A1%E7%AB%AF%E5%AE%89%E8%A3%85/01.png?raw=true" alt="01"><figcaption class="figure__caption">01</figcaption></figure></p>
<p><figure class="figure"><img src="https://github.com/hcldirgit/image/blob/master/zabbix%20%E6%9C%8D%E5%8A%A1%E7%AB%AF%E5%AE%89%E8%A3%85/02.png?raw=true" alt="02"><figcaption class="figure__caption">02</figcaption></figure></p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;然后重启 zabbix-server 服务</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">[root@zabbix ~]<span class="comment"># /etc/init.d/zabbix-server restart</span></div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;再次查看 zabbix_server 服务已启动</p>
<p><figure class="figure"><img src="https://github.com/hcldirgit/image/blob/master/zabbix%20%E6%9C%8D%E5%8A%A1%E7%AB%AF%E5%AE%89%E8%A3%85/03.png?raw=true" alt="03"><figcaption class="figure__caption">03</figcaption></figure></p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;下面通过浏览器安装 zabbix</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;浏览器访问 <a href="http://ip/zabbix" target="_blank" rel="external">http://ip/zabbix</a> ，默认会有 “It is not safe to rely on the system‘s timezone settings ” 这样的警告信息</p>
<p><figure class="figure"><img src="https://github.com/hcldirgit/image/blob/master/zabbix%20%E6%9C%8D%E5%8A%A1%E7%AB%AF%E5%AE%89%E8%A3%85/04.png?raw=true" alt="04"><figcaption class="figure__caption">04</figcaption></figure></p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;需要</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">[root@zabbix ~]<span class="comment"># vim /etc/php.ini</span></div></pre></td></tr></table></figure>
<p><figure class="figure"><img src="https://github.com/hcldirgit/image/blob/master/zabbix%20%E6%9C%8D%E5%8A%A1%E7%AB%AF%E5%AE%89%E8%A3%85/05.png?raw=true" alt="05"><figcaption class="figure__caption">05</figcaption></figure></p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;修改为</p>
<p><figure class="figure"><img src="https://github.com/hcldirgit/image/blob/master/zabbix%20%E6%9C%8D%E5%8A%A1%E7%AB%AF%E5%AE%89%E8%A3%85/06.png?raw=true" alt="06"><figcaption class="figure__caption">06</figcaption></figure></p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;点 next，会提示有一些参数不合适，需要通过编辑配置文件 /etc/php.ini ，解决相关的报错信息</p>
<p><figure class="figure"><img src="https://github.com/hcldirgit/image/blob/master/zabbix%20%E6%9C%8D%E5%8A%A1%E7%AB%AF%E5%AE%89%E8%A3%85/07.png?raw=true" alt="07"><figcaption class="figure__caption">07</figcaption></figure></p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;更改完成，重启 apache 服务</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">[root@zabbix ~]<span class="comment"># service httpd restart</span></div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;点 retry，所有参数提示 OK</p>
<p><figure class="figure"><img src="https://github.com/hcldirgit/image/blob/master/zabbix%20%E6%9C%8D%E5%8A%A1%E7%AB%AF%E5%AE%89%E8%A3%85/08.png?raw=true" alt="08"><figcaption class="figure__caption">08</figcaption></figure></p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;点 next</p>
<p><figure class="figure"><img src="https://github.com/hcldirgit/image/blob/master/zabbix%20%E6%9C%8D%E5%8A%A1%E7%AB%AF%E5%AE%89%E8%A3%85/09.png?raw=true" alt="09"><figcaption class="figure__caption">09</figcaption></figure></p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;输入 mysql 相关配置，点  test connection 测试</p>
<p><figure class="figure"><img src="https://github.com/hcldirgit/image/blob/master/zabbix%20%E6%9C%8D%E5%8A%A1%E7%AB%AF%E5%AE%89%E8%A3%85/10.png?raw=true" alt="10"><figcaption class="figure__caption">10</figcaption></figure></p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;显示 OK，点 next</p>
<p><figure class="figure"><img src="https://github.com/hcldirgit/image/blob/master/zabbix%20%E6%9C%8D%E5%8A%A1%E7%AB%AF%E5%AE%89%E8%A3%85/11.png?raw=true" alt="11"><figcaption class="figure__caption">11</figcaption></figure></p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Name 写 127.0.0.1 （这个可以自定义）</p>
<p><figure class="figure"><img src="https://github.com/hcldirgit/image/blob/master/zabbix%20%E6%9C%8D%E5%8A%A1%E7%AB%AF%E5%AE%89%E8%A3%85/12.png?raw=true" alt="12"><figcaption class="figure__caption">12</figcaption></figure></p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;继续点 next</p>
<p><figure class="figure"><img src="https://github.com/hcldirgit/image/blob/master/zabbix%20%E6%9C%8D%E5%8A%A1%E7%AB%AF%E5%AE%89%E8%A3%85/13.png?raw=true" alt="13"><figcaption class="figure__caption">13</figcaption></figure></p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;再点 next</p>
<p><figure class="figure"><img src="https://github.com/hcldirgit/image/blob/master/zabbix%20%E6%9C%8D%E5%8A%A1%E7%AB%AF%E5%AE%89%E8%A3%85/14.png?raw=true" alt="14"><figcaption class="figure__caption">14</figcaption></figure></p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;点 finish ，进入登录页面，默认帐号 admin 密码 zabbix</p>
<p><figure class="figure"><img src="https://github.com/hcldirgit/image/blob/master/zabbix%20%E6%9C%8D%E5%8A%A1%E7%AB%AF%E5%AE%89%E8%A3%85/15.png?raw=true" alt="15"><figcaption class="figure__caption">15</figcaption></figure></p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;输入帐号密码登录</p>
<p><figure class="figure"><img src="https://github.com/hcldirgit/image/blob/master/zabbix%20%E6%9C%8D%E5%8A%A1%E7%AB%AF%E5%AE%89%E8%A3%85/16.png?raw=true" alt="16"><figcaption class="figure__caption">16</figcaption></figure></p>

	

	
		<span class="different-posts"><a href="/2017/10/12/Zabbix/2. zabbix 服务端安装/" onclick="window.history.go(-1); return false;">⬅️ Go back </a></span>

	

</article>

	</main>

	<footer class="footer">
	<div class="footer-content">
		
	      <div class="footer__element">
	<p>Hi there, <br />welcome to my Blog glad you found it. Have a look around, will you?</p>
</div>

	    
	      <div class="footer__element">
	<h5>Check out</h5>
	<ul class="footer-links">
		<li class="footer-links__link"><a href="/archives">Archive</a></li>
		
		  <li class="footer-links__link"><a href="/atom.xml">RSS</a></li>
	    
		<li class="footer-links__link"><a href="/about">about page</a></li>
		<li class="footer-links__link"><a href="/tags">Tags</a></li>
		<li class="footer-links__link"><a href="/categories">Categories</a></li>
	</ul>
</div>

	    

		<div class="footer-credit">
			<span>© 2017 失落的乐章 | Powered by <a href="https://hexo.io/">Hexo</a> | Theme <a href="https://github.com/HoverBaum/meilidu-hexo">MeiliDu</a></span>
		</div>

	</div>


</footer>



</body>

</html>
